package summary;

/**
 * @Author: 海琳琦
 * @Date: 2022/3/11 17:23
 * https://leetcode-cn.com/problems/coin-change-2/
 */
public class Title518 {

    /**
     * dp[i]表示装满容量为i的背包所需要的方案数
     * 递推公式：dp[j] += dp[j-nums[i]]
     * 初始化：dp[0] = 1
     * @param amount
     * @param coins
     * @return
     */
    public int change(int amount, int[] coins) {
        int[] dp = new int[amount + 1];
        dp[0] = 1;
        for (int i = 0; i < coins.length; i++) {
            for (int j = coins[i]; j <=amount ; j++) {
                dp[j] += dp[j] - coins[i];
            }
        }
        return dp[amount];
    }

    public static void main(String[] args) {

    }
}
